<template>
  <div class="layout">
    <header>
      <ul>
        <li
          :class="{'active':selcetIndex === index}"
          v-for="(item,index) in navsList"
          :key="index"
          @click="toPage(item,index)"
        >{{item.title}}</li>
      </ul>
    </header>
    <div class="main">
      <router-view />
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      selcetIndex: 0,
      navsList: [
        { title: "首页", path: "/Home" },
        { title: "一张图应用", path: "/OneMap" },
      ],
    }
  },
  methods: {
    toPage(item, index) {
      if (this.$route.path !== item.path) {
        this.selcetIndex = index
        this.$router.push(item.path)
      }
    },
  },
}
</script>

<style lang="less" scoped>
.layout {
  width: 100%;
  height: 100%;
}
header {
  height: 58px;
  user-select: none;
  background: #999;
  ul {
    display: flex;
    li {
      padding: 0 20px;
      line-height: 58px;
      cursor: pointer;
      &.active {
        background: white;
      }
    }
  }
}
.main {
  height: calc(100% - 58px);
  overflow: hidden;
  overflow-y: auto;
}
</style>